#include <conio.h>
#include "FONT.H"
#include "INPUT.H"

int main()
{
	int tInput;
	int x = 0;
	int y = 0;
	int i;	
	int state = 0;
	Fonts fonts;
	boolean fontEnable = loadFonts("FONT.FNT", &fonts);
	setMode(VGA_MODE);
	while(TRUE){
		if(kbhit()){
			tInput = getKey();
			if(tInput == 27){
				break;
			}
			if(tInput == 13){
				state+=32;
				if(state >=128){
					state =0;
				}
			}
		}		
		setBackground(LIGHT_BLUE);				
		if(fontEnable)
		{
			x = 0;
			y = 0;			
			for(i=state;i<state+32 && state<=126;i++)
			{
				if(x+fonts.fonts[fonts.map[i]].width > SCREEN_WIDTH)
				{
					x = 0;
					y += (fonts.defaultSymbol.height+2);
				}
				drawFont(fonts,i, x, y, RED);
				x += (fonts.fonts[fonts.map[i]].width+2);
			}
		}
		redraw();
		delay(33);
	}	
	setMode(TEXT_MODE);
	freeFonts(&fonts);
	return EXIT_SUCCESS;
}